-
Notifications
You must be signed in to change notification settings - Fork 239
Change exit code when sncast returns error #3775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Add ExitStatus enum similar to snforge - Update main() to exit with appropriate codes: * 0 for success * 1 for command failures (RPC errors, contract errors, etc.) * 2 for unexpected errors (invalid arguments) - Update process_command_result to return ExitStatus - Update all command handlers to return ExitStatus - Catch errors at top level and convert to ExitStatus::Failure Co-authored-by: cptartur <[email protected]>
- Add integration tests for exit code behavior - Add manual verification script - All tests pass: exit 0 for success, 1 for failures, 2 for invalid args Co-authored-by: cptartur <[email protected]>
@copilot instead of introducing all this logic focus on |
Instead of adding ExitStatus enum and complex logic, the simpler solution: - Updated process_command_result to return Result<()> instead of void - Added ? operator to propagate errors naturally - Errors now flow through anyhow's default handling (exit 1) - Invalid args still return exit 2 via clap This approach is much cleaner and leverages Rust's existing error handling. Co-authored-by: cptartur <[email protected]>
Updated in 55c0db2. Changed Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@copilot rebase branch and resolve conflicts |
Rebased onto master. The changes were applied cleanly after accounting for
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@copilot resolve conflicts |
Conflicts resolved by rebasing onto latest master. Changes applied cleanly -
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
Fixed
sncast
to return proper exit codes on error/failure by updatingprocess_command_result()
to propagate errors naturally.Exit Codes
Implementation
Updated
process_command_result
inhelpers/command.rs
to returnResult<()>
instead ofExitCode
. Added?
operators at all call sites to propagate errors through the call chain.When a command fails:
ui.eprintln()
Err(err)
and propagates tomain()
main()
returns the error, which anyhow converts to exit code 1This leverages Rust's existing error handling infrastructure instead of introducing new abstractions.
Testing
All exit codes manually verified:
sncast show-config
returns 0sncast call --url http://testinvalid ...
returns 1sncast invalid-cmd
returns 2Fixes #3684
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.